moria.de Michael's home page Computing CP/M 2.2 with real BIOS on YAZE

Using CP/M 2.2 on YAZE with a real BIOS instead of its BIOS emulation

Introduction

YAZE is an excellent Z80 simulator, written in ANSI C, that works on many architectures. It is fast, simulates undocumented opcodes and passes instruction regression tests against real Z80 hardware.

As distributed, YAZE is configured to include BIOS emulation. That enables such features as changing virtual disks on the fly and virtual disks that are mapped to files at run time, instead of using files that contain disk images.

Although BIOS emulation offers interesting features, some people prefer using simulated hardware, for various reasons. That hardware is accessed using I/O ports, like Udo Munk's z80pack does. This page explains how to set up a CP/M 2.2 compatible system using YAZE configured without BIOS emulation.

Building yaze and cpmtools

Modify the yaze Makefile by removing -DBIOS from OPTIONS, comment out the line with YAZE_OBJS for "Link with CP/M BIOS support," and uncomment the YAZE_OBJS for "or link as a naked Z80". Compile yaze. That should be all that's needed.

Further get, compile and install cpmtools. You will need it to transfer files between UNIX and CP/M file systems and to generate your boot disk image.

The disk boot loader

If you want to boot from a (virtual) floppy, then you need a disk boot loader that resides in ROM. The Z80 starts execution at address 0x0000, so that's where the loader has to be. Real hardware often contains a ROM there, that is disabled after booting. I simply boot yaze with the boot loader being loaded at that address. The loader relocates itself to address 0x2000, then loads the first sector of the floppy to 0x0000. Finally it transfers control to the boot sector of the floppy it just loaded by jumping to address 0x0000. If you do not already have CP/M running, then download the assembled rom disk boot loader diskboot.rom. This disk boot loader is independent of the used operating system.

The boot sector

The boot sector is the first sector of the floppy. It will load the CCP, BDOS and BIOS from the system tracks to memory and starts CP/M. For that reason, it needs to know how long CP/M is, so it is OS specific. It further needs to know the floppy format. I use a 3740 format with 77 tracks, 26 sectors a 128 byte and a skew factor of 6 for the virtual floppy drives A and B, like Udo Munk's z80pack, so I can use a modified version of his boot sector. If you do not yet have a CP/M system running, then download the assembled binary bootload.sys.

The CCP and the BDOS

Although you could use the CP/M 2.2 CCP, I suggest you use Z80CCP which has some nice additional features. Download the assembled binary z80ccp.sys. Same for BDOS: You could use the CP/M 2.2 BDOS, but P2DOS offers additional features, so I suggest you use that. Download its assembled binary p2dos.sys.

The BIOS

I started by using Udo Munk's BIOS from z80pack, but hacked it to use virtual 4MB HDs as drives C and D, using the iobyte, offering offer date and time functions. Further I fixed some bugs. Download the assembled binary bios.sys and you are almost done.

Building the boot disk

If you were running CP/M, you would load all *.sys files using DDT and then write them to the system tracks with SYSGEN. You can also use mkfs.cpm to do so, after all your floppy is simulated by an image file of its contents:

mkfs.cpm -b bootload.sys -b z80ccp.sys -b p2dos.sys -b bios.sys p2dos

Now you have a floppy image called p2dos, that can be booted. But wait, you need to be able to halt yaze somehow. So download one more file: halt.com. Copy it to your image:

cpmcp p2dos halt.com 0:

It may be a good idea to copy all CP/M 2.2 transient commands to the same disk, but that is not neccessary to check that all works. Now you are done.

Starting the system

You need to tell the I/O port simulation in yaze which files to use. I have a default configuration file in /usr/cpm/etc/p2dos:

mount a p2dos
mount b scratch
mount c hdc
mount d hdd
attach rdr /dev/null
attach lst lst
attach pun /dev/null
Adapt it for your system. Then generate blank disk images using mkfs.cpm. Use the flag -f 4mb-hd for drive C and D. That's it, you are ready to boot:

/usr/cpm/bin/yaze -l 0 -b diskboot.rom -s /usr/cpm/etc/p2dos

Yet Another Z80 Emulator version 1.10, Copyright 1995,1998 Frank D. Cringle.
yaze comes with ABSOLUTELY NO WARRANTY; for details
see the file "COPYING" in the distribution directory.


A0>
If you are done, start the command halt and yaze will exit. To simplify live, I keep my disk images in $HOME/cpm and use the following shell script:
#!/bin/sh

if [ ! -d $HOME/cpm ]
then
  echo Creating $HOME/cpm ...
  mkdir $HOME/cpm
  cp /usr/cpm/disks/p2dos $HOME/cpm/p2dos
  cp /usr/cpm/disks/scratch $HOME/cpm/scratch
  cp /usr/cpm/disks/hd $HOME/cpm/hd
fi

cd $HOME/cpm

if [ x$1 = x ]
then
  RC=/usr/cpm/etc/p2dos
else
  RC=$HOME/cpm/$1
fi

exec /usr/cpm/bin/yaze -l 0 -b /usr/cpm/rom/diskboot.rom -s $RC
You will probably have to adapt it to your needs.

Sources

Now that all works, you may want to get kit.tar.gz, which contains zsm, zlink, the sources and submit files for everything. You probably have to modify the submit files to reflect your configuration, e.g. drive names. If you change the BIOS length, then do not forget to change the CCP and BDOS origins, as well as the boot sector. I use a free SUBMIT clone, because once I had some problems with CP/M 2.2 SUBMIT. Unfortunately, I forgot what the problem was. If you get trouble, then copy sub.com to submit.com. Be warned that I hacked most files. If you are interested in the originals, then check your nearest oakland ftp mirror.

Have fun!